/*
CREDITS:
Sprites - Inferno Interactive (Shadow Warrior expansion)
Rip - Zero X. Diamond
Original scripting by Woodchuck, refined by KeksDose.

Sounds:
Up - ?
Fire - ?
Add Fire - ? (Uhh, I didn't pay attention too much from where I got sounds for that, it seems.)
Full - ID (Doom 3)
*/

ACTOR SchwarzerZwerg : Weapon 24503
{
   //$Category Weapons
   //$Title Schwarzer Zwerg
   //$Sprite CSGGX0
   Tag "Schwarzer Zwerg"
   Inventory.PickupSound "misc/w_pkup"
   Inventory.PickupMessage "You got the ''Schwarzer Zwerg'' chain-fed super shotgun! That's not a midget... that's a mass murderer! (3)"
   Obituary "%o was evidently botched by %k's ''Schwarzer Zwerg''."
   Weapon.UpSound "Weapons/SchwarzerZwergUp"
   Weapon.SelectionOrder 6
   Weapon.AmmoType "ErasusAmmo"
   Weapon.AmmoType2 "ZwergClip"
   Weapon.AmmoUse 2
   Weapon.AmmoUse2 0
   Weapon.AmmoGive 30
   Weapon.AmmoGive2 0
   Weapon.Kickback 35
   Weapon.SlotNumber 3
   +NOALERT
   +AMMO_OPTIONAL
   Scale 1
   States
   {
   Spawn:
      CSGG X -1
      Stop
   Ready:
      CSGG A 1 A_WeaponReady
	  TNT1 A 0 A_JumpIfInventory("RO_GotoReload", 1, "Reload")
      Loop
   Nope:
      CSGL A 0 A_PlaySound("Weapons/SchwarzerZwergFull")
      CSGL A 8 A_WeaponReady(WRF_NOFIRE)
      CSGG A 8 A_WeaponReady(WRF_NOFIRE)
      Goto Ready
   Deselect:
      //old CSGG A 0 ACS_Execute (958, 0, 0, 0, 0)
      CSGG A 0 A_ZoomFactor(1)
      CSGG A 1 A_Lower
      CSGG A 0 A_Lower
      Loop
	Select:
      CSGG A 1 A_Raise
      CSGG A 0 A_Raise
      //old CSGG A 0 A_LogInt(Tid) //Thing_ChangeTID(0,2000)
      Loop
   Fire:
      CSGF A 0 A_JumpIfInventory("ZwergClip",2,"PowerFire")
      CSGF A 0 A_JumpIfInventory("ErasusAmmo",2,1)
      Goto Nope
      CSGF A 0 A_PlaySoundEx("Weapons/SchwarzerZwergFire","Auto")
      CSGF A 0 A_PlaySound("Weapons/SchwarzerZwergFirey",6,0.7)
      CSGF A 0 A_GiveInventory("ErasusCasing",2)
      ERAF A 0 A_AlertMonsters
      CSGF A 0 A_JumpIfInventory("QuadUpgrade",1,"QuadFire")
      CSGF A 0 A_FireBullets(14.5, 2.75, 30, 18, "ErasusPuff",1)
      Goto Refraction
   QuadFire:
      ERAF A 0 A_SetBlend("Blue",0.05,12)
      ERAF A 0 A_PlaySoundEx("Weapons/QuadShot","SoundSlot5")
      ERAF A 0 A_FireBullets(14.5, 2.75, 30, 36, "QuadPuff",1)
      Goto Refraction
   Refraction:
      CSGF A 0 A_ZoomFactor(0.975)
      CSGF A 0 A_Recoil(3)
	  CSGF AB 1 BRIGHT ACS_Execute(851,0,40+random(15,-15),20+random(6,-6),0)
      CSGG A 0 A_ZoomFactor(1)
      CSGG BC 1 ACS_Execute(851,0,-15+random(6,-3),-5+random(3,-3),0)
      CSGG C 0 A_ReFire
      CSGG BDE 1 ACS_Execute(851,0,-15+random(6,-3),-5+random(3,-3),0)
      CSGF A 0 A_PlayWeaponSound("Weapons/SchwarzerZwergLoad")
      CSGG A 3
      CSGL ABCABC 2
      CSGL A 3
      CSGG A 1
      Goto Ready
   Hold:
      CSGF A 0 A_JumpIfNoAmmo("Nope")
      CSGF A 0 A_GunFlash
      CSGF A 0 A_PlaySoundEx("Weapons/SchwarzerZwergFire",SoundSlot5)
      CSGF A 0 A_PlaySound("Weapons/SchwarzerZwergFirey",6,0.7)
      CSGF A 0 A_Recoil(3)
      CSGF A 0 Radius_Quake(2,4,0,32,0)
      CSGF A 0 A_ZoomFactor(0.94)
      CSGF A 0 A_GiveInventory("ErasusCasing",2)
      ERAF A 0 A_JumpIfInventory("QuadUpgrade",1,"QuadHold")
      CSGF A 0 A_FireBullets(14.5, 2.75, 30, 18, "ErasusPuff",1)
      Goto HoldRefraction
   QuadHold:
      ERAF A 0 A_SetBlend("Blue",0.05,12)
      ERAF A 0 A_PlaySoundEx("Weapons/QuadShot","Normal")
      ERAF A 0 A_FireBullets(14.5, 2.75, 30, 36, "QuadPuff",1)
      Goto HoldRefraction
   HoldRefraction:
      CSGA AB 1 BRIGHT ACS_Execute(851,0,35+random(7,-7),15+random(7,-7),0)
      CSGA C 1
      CSGL A 1
      CSGL A 0 A_JumpIfNoAmmo(2)
      CSGL A 0 A_ReFire
      CSGF A 0 A_PlayWeaponSound("Weapons/SchwarzerZwergLoad")
      CSGL A 1 A_ZoomFactor(0.95)
      CSGL A 1 A_ZoomFactor(0.96)
      CSGL A 1 A_ZoomFactor(0.97)
      CSGL A 0 A_StopSoundEx("Auto")
      CSGL A 1 A_ZoomFactor(0.98)
      CSGL A 1 A_ZoomFactor(0.985)
      CSGL B 1 A_ZoomFactor(0.99)
      CSGL B 1 A_ZoomFactor(0.995)
      CSGL C 1 A_ZoomFactor(1)
      CSGL C 1
      CSGL ABC 2
      CSGL A 3
      CSGG A 1
      Goto Ready
   PowerFire:
      //YE OLDE STANDARD FIRE CRAP
      CSGG A 0 A_GunFlash
      CSGG A 0 A_AlertMonsters
      CSGF A 0 A_PlaySoundEx("Weapons/SchwarzerZwergFire","Auto")
      CSGF A 0 A_PlaySound("Weapons/SchwarzerZwergFirey",6,0.7)
	  //QUAD UPGRADE BULLSHEET
      CSGF A 0 A_JumpIfInventory("QuadUpgrade",1,"QuadTrueFire")
      CSGF A 0 A_FireBullets(14.5 + ACS_ExecuteWithResult(707) * 0.85,
							 2.75 + ACS_ExecuteWithResult(707) * 0.4, 30*ACS_ExecuteWithResult(707), 18, "ErasusPuff", 0)
      Goto Pootis
   QuadTrueFire:
      CSGF A 0 A_SetBlend("Blue",0.05,12)
      CSGF A 0 A_FireBullets(14.5 + ACS_ExecuteWithResult(707) * 0.85,
							 2.75 + ACS_ExecuteWithResult(707) * 0.4, 30*ACS_ExecuteWithResult(707), 36, "QuadPuff", 0)
      CSGF A 0 A_PlaySoundEx("Weapons/QuadShot","SoundSlot5")
      Goto Pootis
   Pootis:
      CSGF A 1 BRIGHT
	  //ZWERG CLIP MACHINATIONS
      CSGF A 0 A_Recoil(3 + (ACS_ExecuteWithResult(707) * 2.0))
	  CSGG A 0 A_SetPitch(pitch-(ACS_ExecuteWithResult(707)*0.95))
	  CSGG A 0 A_SetAngle(angle-(ACS_ExecuteWithResult(707)*0.65))
      CSGG A 0 A_ZoomFactor(1 -(ACS_ExecuteWithResult(707)*0.0075))
      CSGF A 0 A_GiveInventory("ErasusCasing",0+ACS_ExecuteWithResult(707))
	  //MAIN FIRE ANIM CRAP
   Spencer:
      CSGG A 0 A_TakeInventory("ZwergClip",99)
      CSGF B 1 BRIGHT
      CSGG BCBD 1
      CSGG E 1 A_ZoomFactor(0.99)
      CSGG A 0 A_PlayWeaponSound("Weapons/SchwarzerZwergLoad")
      CSGG A 1 A_ZoomFactor(0.995)
      CSGG A 1 A_ZoomFactor(1)
      CSGG A 1
      CSGL ABCABC 2
      CSGL A 3
      CSGG A 1
      Goto Ready
   AltFire:
      CSGG A 0 A_JumpIfInventory("ErasusAmmo",2,1)
      Goto Nope
      CSGG A 0 A_JumpIfInventory("ZwergClip",0,"Nope")
      CSGG A 0 A_PlaySoundEx("Weapons/SchwarzerZwergAlt","SoundSlot5")

      CSGG A 0 A_TakeInventory("ErasusAmmo",1,TIF_NOTAKEINFINITE)
      CSGG A 0 A_GiveInventory("ZwergClip",1)
      CSGL AB 2
      CSGL C 1
      CSGG A 0 A_TakeInventory("ErasusAmmo",1,TIF_NOTAKEINFINITE)
      CSGG A 0 A_GiveInventory("ZwergClip",1)
      CSGL AB 2
      CSGL C 1
      CSGG A 0 A_WeaponReady(WRF_NoBob|WRF_NoPrimary)
      Goto Ready
   Reload:
      CSGG A 0 A_JumpIfInventory("ErasusAmmo", 0, "NopeItsFull")
      CSGG A 0 A_JumpIfInventory("ZwergClip", 1, 2)
      CSGG A 0 A_Print("There are no shells to unload.")
	  Goto Nope
   ReloadLoop:
      CSGG A 0 A_JumpIfInventory("ErasusAmmo",0,"ReturnShells")
      CSGG A 0 A_JumpIfInventory("ZwergClip",1,1)
	  Goto ReturnShells
      CSGG A 0 A_TakeInventory("ZwergClip",1)
      CSGG A 0 A_GiveInventory("ErasusAmmo",1)
	  Goto ReloadLoop
   ReturnShells:
      CSGG A 0 A_PlaySound("Weapons/SchwarzerZwergAlt",5)
      CSGG A 0 A_Print("Unloaded shells...")
      CSGL CB 2
      CSGL A 2
      CSGL CB 2
      CSGL A 2
	  CSGG A 6
      Goto Ready
   NopeItsFull:
      CSGG A 0 A_Print("Ammo capacity reached full; cannot proceed with the unload process.")
	  Goto Nope
   Flash:
       TNT1 A 2 Bright A_Light2
       TNT1 A 1 A_Light1
       TNT1 A 0 A_Light0
       Stop
   }
}

actor ZwergClip : Ammo
{
	Inventory.Amount 30
	Inventory.MaxAmount 30
	ammo.backpackamount 0
	ammo.backpackmaxamount 30
	Inventory.Icon "CSGGX0"
}
